package com.yyx.up.analysis.uf.mapper;

import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.Text;

import java.io.IOException;

/**
 * Description: 分析数据的mapper
 * @Author: yyx
 * @Create: 2023/5/5 19:44
 * @Version: 8
 */
public class AnalysisTextMapper extends TableMapper<Text,Text> {
    @Override
    protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
        String rowkey = Bytes.toString(key.get());//Bytes.toString解析数据
        //5_19683537146_20221025055816_02_0571_1
        String[] values = rowkey.split("_");
        String tel = values[1];
        String film = values[3];
        String watchtime = values[2];
        String duration = values[4];

        // 观影数据
        context.write(new Text(tel + "_" + film),new Text(duration));
    }
}
